<?php
$client = $this->client;
$clientVente = $this->clientVente;
$clientModel = new Admin_Model_Clients()
?>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span3"><?php echo $this->partial('choix/menu.phtml') ?></div>
        <div class="span9">
            <div class="wrap">
                <div id="main-content">
					<form action="<?php echo $this->baseUrl('admin/clients/save') ?>" method="post" name="formCli" class="form-horizontal">
					    <input type="hidden" name="num_vente" value="<?php echo $this->request()->getParam('num_vente') ?>" />
					    <input type="hidden" name="id" value="<?php echo $this->request()->getParam('id') ?>" />
					    <h3>Edition</h3>
					    <?php if ($this->request()->getParam('id')) : ?>
					        <p align="center"><a href="<?php echo $this->baseUrl('admin/clients/save-pdf/?id=' . $client->getPClients()) ?>&num_vente=<?php echo $this->request()->getParam('num_vente') ?>">Fichier PDF</a></p>
					    <?php endif ?>
					    <?php echo $this->partial('_message.phtml') ?>
					    <ul class="nav nav-tabs" id="edit-form-tab">
					        <li class="active">
                                <a href="#frm1">Généralités</a>
                            </li>
                            <li>
                                <a href="#frm2">Adresse</a>
                            </li>
                            <li>
                                <a href="#frm3">Archiver</a>
                            </li>
                            <li>
                                <a href="#frm4">Other</a>
                            </li>
					    </ul>
    					<!--
    					<?php //if($this->org == "all") { ?>
    						<p align="center"><input name="btn_prev" type="image" value="previous" src="images/gauche.png" onclick="document.formCli.submit()" class="chk" /> <input name="btn_next" type="image" value="next" src="images/droite.png" onclick="document.formCli.submit()" class="chk" /></p>
    					<?php //} ?>
					    -->
					    <div class="tab-content">
    					    <div class="tab-pane active" id="frm1">
        					    <div class="control-group">
                                    <label class="control-label" for="pays-name">Type de client : </label>
                                    <div class="controls">
                                        <label>
                                            <input name="client[vendeur]" type="checkbox" class="chk" id="vendeur" value="1" <?php if($client->getVendeur() == 1) { echo " checked"; } ?> />
        								    Vendeur&nbsp;&nbsp;
        								</label>
        								<label>
        								    <input name="client[acheteur]" type="checkbox" class="chk" id="acheteur" value="1" <?php if($client->getAcheteur() == 1) { echo " checked"; } ?> />
        								    Acheteur&nbsp;&nbsp;
        							    </label>
        							    <label>
        								    <input name="client[contact]" type="checkbox" class="chk" id="contact" value="1" <?php if($client->getContact() == 1) { echo " checked"; } ?> />
        								    Contact
        							    </label>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="num_client">N&deg; : </label>
                                    <div class="controls">
                                        <input type="text" name="vente[num_client]" id="num_client" value="<?php echo ($clientVente->getNumClient() != 'n') ? (int) $clientVente->getNumClient() : $clientVente->getNumClient() ?>" size="4" maxlength="45" placeholder="N&deg;" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">Catégorie : </label>
                                    <div class="controls">
                                        <label>
                                            <input name="client[bd]" type="checkbox" class="chk" id="checkbox" value="1" <?php if($client->getBd() == 1) { echo " checked"; } ?> />
        								    BD&nbsp;&nbsp;
        							    </label>
        							    <label>
        								    <input name="client[obj]" type="checkbox" class="chk" id="checkbox" value="1" <?php if($client->getObj() == 1) { echo " checked"; } ?> />
        								    Objet&nbsp;&nbsp;
        							    </label>
        							    <label>
        								    <input name="client[fg]" type="checkbox" class="chk" id="checkbox" value="1" <?php if($client->getFg() == 1) { echo " checked"; } ?> />
        								    Fond de grenier
        							    </label>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="commission">%Com : </label>
                                    <div class="controls">
                                        <input name="vente[commission]" type="text" id="commission" size="4" maxlength="4" value="<?php echo $clientVente->getCommission() ?>" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="userid">UserID : </label>
                                    <div class="controls">
                                        <input name="client[userid]" id="userid" type="text" value="<?php echo stripslashes($client->getUserid()) ?>" placeholder="UserID" required="required" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="email">Email : </label>
                                    <div class="controls">
                                        <input name="client[email]" id="email" type="text" value="<?php echo stripslashes($client->getEmail()) ?>" placeholder="Email" required="required" />
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane" id="frm2">
                                <div class="control-group">
                                    <label class="control-label" for="nom">Nom : </label>
                                    <div class="controls">
                                        <input name="client[nom]" id="nom" type="text" id="nom" value="<?php echo stripslashes($client->getNom()) ?>" placeholder="Nom" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="prenom">Pr&eacute;nom : </label>
                                    <div class="controls">
                                        <input name="client[prenom]" id="prenom" type="text" id="nom" value="<?php echo stripslashes($client->getPrenom()) ?>" placeholder="Pr&eacute;nom" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="co">C/O : </label>
                                    <div class="controls">
                                        <input name="client[co]" id="co" type="text" id="nom" value="<?php echo stripslashes($client->getCo()) ?>" placeholder="C/O" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="adresse">Adresse : </label>
                                    <div class="controls">
                                        <input name="client[adresse]" id="adresse" type="text" value="<?php echo stripslashes($client->getAdresse()) ?>" placeholder="Adresse" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="adresse2">Adresse (suite) : </label>
                                    <div class="controls">
                                        <input name="client[adresse2]" id="adresse2" type="text" value="<?php echo stripslashes($client->getAdresse2()) ?>" placeholder="Adresse (suite)" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="cp">Code Postal : </label>
                                    <div class="controls">
                                        <input name="client[cp]" id="cp" type="text" value="<?php echo stripslashes($client->getCp()) ?>" placeholder="Code Postal" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="civilite">Civilit&eacute; : </label>
                                    <div class="controls">
                                        <select name="client[f_civilites]" id="civilite">
        								<?php
        									$selected = '';
        									$listCity = $clientModel->getListCity();
        									foreach($listCity as $city) :
        								?>
        										<option value="<?php echo $city['p_civilites']?>" <?php if ($city['p_civilites'] == $client->getFCivilites()) : ?>selected<?php endif ?>>
        										    <?php echo $city['nom']?>
    										    </option>
        								<?php endforeach;?>
        								</select>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="ville">Ville : </label>
                                    <div class="controls">
                                        <input name="client[ville]" id="ville" type="text" value="<?php echo stripslashes($client->getVille()) ?>" placeholder="Ville" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="pays">Pays : </label>
                                    <div class="controls">
                                        <select name="client[f_pays]" id="pays">
            							<?php
            								$listPay = $clientModel->getListPay();
            								foreach($listPay as $pay) :
            							?>
            									<option value="<?php echo $pay['p_pays']?>" <?php if ($pay['p_pays'] == $client->getFPays()) : ?>selected<?php endif ?>>
            									    <?php echo $pay['nom'] ?>
        									    </option>;
            								<?php endforeach;?>
            							</select>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="tel1">T&eacute;l 1 : </label>
                                    <div class="controls">
                                        <input name="client[tel1]" id="tel1" type="text" value="<?php echo stripslashes($client->getTel1()) ?>" placeholder="T&eacute;l 1" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="tel2">T&eacute;l 2 : </label>
                                    <div class="controls">
                                        <input name="client[tel2]" id="tel2" type="text" value="<?php echo stripslashes($client->getTel2()) ?>" placeholder="T&eacute;l 2" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="tel3">T&eacute;l 3 : </label>
                                    <div class="controls">
                                        <input name="client[tel3]" id="tel3" type="text" value="<?php echo stripslashes($client->getTel3()) ?>" placeholder="T&eacute;l 3" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="tel4">T&eacute;l 4 : </label>
                                    <div class="controls">
                                        <input name="client[tel4]" id="tel4" type="text" value="<?php echo stripslashes($client->getTel4()) ?>" placeholder="T&eacute;l 4" />
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane" id="frm3">
                                <div class="control-group">
                                    <label class="control-label" for="banque">N&deg; Compte : </label>
                                    <div class="controls">
                                        <input name="client[compte_banque]" id="banque" type="text" value="<?php echo stripslashes($client->getCompteBanque()) ?>" placeholder="N&deg; Compte" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="identite">N&deg; Carte identit&eacute; : </label>
                                    <div class="controls">
                                        <input name="client[num_identite]" id="identite" type="text" value="<?php echo stripslashes($client->getNumIdentite()) ?>" placeholder="N&deg; Carte identit&eacute;" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="tva">N&deg; TVA : </label>
                                    <div class="controls">
                                        <input name="client[tva]" id="tva" type="text" value="<?php echo stripslashes($client->getTva()) ?>" placeholder="N&deg; TVA" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="archive">Archiver : </label>
                                    <div class="controls">
                                        <input name="client[archive]" type="checkbox" class="chk" id="archive" value="1" <?php if($client->getArchive() == 1) { echo " checked"; } ?> />
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane" id="frm4">
                                <div class="control-group">
                                    <label class="control-label">Catalogue d'office ? </label>
                                    <div class="controls">
                                        <label><input name="client[catoffice]" type="radio" value="0" <?php if($client->getCatoffice() == 0) { echo " checked"; } ?> class="chk" /> Non</label>
                                        <label><input name="client[catoffice]" type="radio" value="1" <?php if($client->getCatoffice() == 1) { echo " checked"; } ?> class="chk" /> Oui</label>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">Contacter vente dépôt</label>
                                    <div class="controls">
                                        <label><input name="client[contact_depot]" type="radio" value="0" <?php if($client->getContactDepot() == 0) { echo " checked"; } ?> class="chk" /> Non</label>
                                        <label><input name="client[contact_depot]" type="radio" value="1" <?php if($client->getContactDepot() == 1) { echo " checked"; } ?> class="chk" /> Oui</label>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">L'utilisateur : </label>
                                    <div class="controls">
                                        <?php
            								if ($client->getDtconfirm() == "") echo "n'a pas encore";
            								else echo "a ";
            								echo " confirmé son inscription";
            							?>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="valid">Banque dessin&eacute;e : </label>
                                    <div class="controls">
                                        <?php
            							if ($client->getDtvalid() == "") echo "n'a pas encore";
            							else echo "a ";
            							echo " validé son inscription<br>";
            							if ($client->getDtvalid() == "") :
            								if ($client->getDtdemandevalid() != "") {
            									echo "L'utilisateur a demandé sa validation le " . dtformatfromdb($client->getDtdemandevalid(), "DD/MM/YYYY") . " à " . $row->hrdemandevalid. "<br />";
            								}
            							?>
            								Autoriser cet utilisateur à placer des ordres d'achats ?<br /><br />
            								<select name="valid" id="valid">
            									<option value="0">Non</option>
            									<option value="1">Oui</option>
            								</select>
            							<?php else : ?>
            								Retirer la validation ?<br /><br />
            								<select name="valid" id="valid">
            									<option value="0">Non</option>
            									<option value="19000101">Oui</option>
            								</select>
            							<?php endif;?>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div align="center" style="width:670px;">
                            <input name="sauver" type="submit" class="btn btn-primary" value=" Sauver " />
                        </div>
					</form>
				</div>
            </div>
        </div>
    </div>
</div>